﻿using System;
using System.Collections.Generic;
using System.Text;
using EasyStudy.Properties;

namespace EasyStudy.Logic.Email
{
    public class SendTasks
    {
        public static void SendTasksEmail(List<EbbinghausTask> tasks, string subject)
        {
            Properties.Settings settings = new Settings();

            EmailSender sender = new EmailSender();
            StringBuilder sb = new StringBuilder();

            sb.AppendLine("<p style=\"font-family:Courier New;\">主人您好：<br><br>&nbsp;&nbsp;&nbsp;您今天有以下任务需要完成。<br><br></p>");
            foreach (EbbinghausTask task in tasks)
            {
                sb.Append("<p style=\"font-family:Courier New;\">" + "主题:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;" + task.Subject + "<br>");
                sb.Append("详情:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;" + task.Comment + "<br>");
                sb.Append("更新时间:&nbsp;&nbsp;" + task.NextTime + "<br>");
                sb.Append("创建时间:&nbsp;&nbsp;" + task.CreateTime + "<br>");
                sb.Append("<br><br></p>");
            }

            sender.EmailBody = sb.ToString();
            sender.SendMail(subject, GlobalSettings.EmailTo, settings.EmailCC, settings.EmailBCC);   
        }
    }
}
